package Demo2;

import java.util.ArrayList;
import java.util.Random;

public class CardOperation {
    //初始化牌库
    public ArrayList<Card> InitCard(ArrayList<Card> arrayList) {
        String[] suits = {"♣", "♦", "♥", "♠"};
        for (int i = 0; i < suits.length; i++) {
            for (int k = 1; k <= 13; k++) {
                Card card = new Card(suits[i], k);
                arrayList.add(card);
            }

        }

        return arrayList;
    }

    //洗牌
    public void changeCard(ArrayList<Card> arrayList) {
        Random random = new Random();
        for (int i = 0; i < 150; i++) {
            int number1 = random.nextInt(52);
            int number2 = random.nextInt(52);
            Card temp = arrayList.get(number1);
            arrayList.set(number1, arrayList.get(number2));
            arrayList.set(number2, temp);
        }
    }
}
